package oldFiles;
import lejos.nxt.MotorPort;

public class SimpleMotor implements SimpleActuator {
	
    private final static int forward  = 1,
	 						 backward = 2,
	 						 stop     = 3;
	
	private MotorPort mp;
	private int mode;
	
	public SimpleMotor(MotorPort mp) {
		this.mp = mp;
		mode = forward;
	}
	
	public SimpleMotor(MotorPort mp, int mode) {
		this.mp = mp;
		this.mode = mode;
	}
	
	
	@Override
	public void setValue(int power) {
		mp.controlMotor(normalize(power), mode);
	}
	
	private int normalize(int value) {
		int returnValue = (value / 20) + 50;
		if (returnValue==50) returnValue = 0;
		return returnValue;
	}

}
